{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1067, 800, 3)\n",
      "(1067, 800)\n",
      "(1067, 800, 1)\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "import cv2 as cv\n",
    "import keras\n",
    "def main():\n",
    "    # [variables]\n",
    "    # Declare the variables we are going to use\n",
    "    ddepth = cv.CV_16S\n",
    "    kernel_size = 3\n",
    "    window_name = \"Laplace Demo\"\n",
    "    # [variables]\n",
    "    # [load]\n",
    "    src = cv.imread(\"123.jpg\", cv.IMREAD_COLOR) # Load an image\n",
    "    print(src.shape)\n",
    "    # [load]\n",
    "    # [reduce_noise]\n",
    "    # Remove noise by blurring with a Gaussian filter\n",
    "    src = cv.GaussianBlur(src, (3, 3), 0)\n",
    "    # [reduce_noise]\n",
    "    # [convert_to_gray]\n",
    "    # Convert the image to grayscale\n",
    "    src_gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)\n",
    "    # [convert_to_gray]\n",
    "    # Create Window\n",
    "    cv.namedWindow(window_name, cv.WINDOW_AUTOSIZE)\n",
    "    # [laplacian]\n",
    "    # Apply Laplace function\n",
    "    dst = cv.Laplacian(src_gray, ddepth, ksize=kernel_size)\n",
    "    # [laplacian]\n",
    "    # [convert]\n",
    "    # converting back to uint8\n",
    "    abs_dst = cv.convertScaleAbs(dst)\n",
    "    xxx = abs_dst.shape\n",
    "    print(abs_dst.shape)\n",
    "    abs_dst = abs_dst.reshape(xxx[0], xxx[1], 1)\n",
    "    print(abs_dst.shape)\n",
    "    # [convert]\n",
    "    # [display]\n",
    "    cv.imshow(window_name, abs_dst)\n",
    "    #cv.waitKey(0)\n",
    "    cv.destroyAllWindows()\n",
    "    # [display]\n",
    "    return 0\n",
    "if __name__ == \"__main__\":\n",
    "    main()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
